home *** CD-ROM | disk | FTP | other *** search
-
- /* --- This source is for Lightspeed C 3.0 or greater --- */
-
- /* image_add_proto.c Main program */
-
- /* InitTheMenus initializes the menus */
- /* about_alert Alerts */
- /* Source_2 Window */
- /* Source_1 Window */
- /* Result Window */
- /* HandleTheMenus Handle the menu selection */
-
- /* Resource file to use is image_add_proto.RSRC */
- /* RMaker file to use is image_add_proto.R */
-
- /* MacTraps use this LSC library from the Mac Libraries fol*/
- /* strings use this LSC library from the Libraries folder */
-
-
- /* ==============================
-
- Program name: image_add_proto.c
- Function: This is the main module for this program.
- History: 4/27/89 Original by Prototyper.
-
- ================================= */
-
- /* *********************************** */
- /* These are the other includes for general routines */
-
- #include <Strings.h>
- extern char *strcpy (Str255 *, char *); /* LSC string prototype */
-
- /* *********************************** */
-
- #define TRUE 1
- #define FALSE 0
- #define NIL 0
-
- /* *********************************** */
-
- /* External routines that are called */
-
- extern void InitMyMenus (void);
-
- /* #include <color.h> */
- /* #include <colortoolbox.h> */
- #include <IM1_5Protos.h>
-
- #include "about_alert.h"
- #include "Source_2.h"
- #include "Source_1.h"
- #include "Result.h"
- #include "HandleTheMenus.h"
- #include "initclut.h"
-
- extern WindowPtr Result_Window;
- extern WindowPtr proton_Window;
- extern WindowPtr flourine_Window;
-
- extern MenuHandle AppleMenu;
- extern MenuHandle FileMenu;
- extern MenuHandle EditMenu;
- extern MenuHandle ModeMenu;
-
- /* global variables */
-
- short pix_zoom;
- short clipboard_empty;
- short add_mode;
- Rect dragRect;
-
-
- /* ====================================== */
- void main (void); /* Prototype for the main module */
- /* ====================================== */
-
-
- void main ()
- {
- char doneFlag; /* Exit program flag */
- char Is_A_Dialog; /* Flag to check for Dialog inputs */
- char stillInGoAway;
- char ch; /* Key pressed in Ascii */
- short code; /* Determine event type */
- short theMenu, theItem; /* Menu list and item selected */
- short chCode; /* Key code */
- long mResult; /* Menu list and item selected values */
- WindowPtr whichWindow; /* See which window for event */
- WindowPtr tempWindow;
- EventRecord myEvent; /* Event record for all events */
- TEHandle theInput;
- Point myPt; /* Temp Point, used in Zoom */
-
- GrafPtr SavePort; /* Place to save the current drawing port */
-
- long scrap_offset; /* holds offset of an item in the scrap/clipboard */
- WindowPtr Current_Window; /* lets us know when DA is in front */
-
- Point mousepos; /* current mouse position */
- char mouse_h[255], mouse_v[255];
- Rect er, r;
-
- static int draw_pos;
-
- /* ---------------------------------------------------------------------- */
-
- InitGraf ( (Ptr) &thePort);
- InitFonts ();
- FlushEvents (everyEvent, 0);
- InitWindows ();
-
- InitMenus ();
- TEInit ();
- InitDialogs (NIL);
- InitCursor (); /* Start with a visible arrow cursor */
-
- MoreMasters();
- MoreMasters();
- MoreMasters();
- MaxApplZone();
-
- OpenResFile ( "\pimage_add_proto.RSRC" ); /* **** Open our resource fi*/
-
- doneFlag = FALSE; /* Do not exit program yet */
-
- dragRect = screenBits.bounds;
- dragRect.top -= MBarHeight;
-
- InitMyMenus ();
-
- theInput = NIL;
-
- Init_gray_clut();
-
- Init_proton ();
- Open_proton ();
- init_clut_proton();
-
- Init_flourine ();
- Open_flourine ();
- init_clut_flourine();
-
- Init_Result ();
- Open_Result ();
- init_clut_result();
-
- pix_zoom = 2; /* initial pixel-zoom value 2/2 = 1,
- zooming goes from 1/2 = 0.5 to 2/2 = 1 to
- 4/2 = 2, to 8/2 = 4 */
-
- Current_Window = NIL;
-
- draw_pos = 50;
-
- do /* Start of main event loop */
- {
- SystemTask ();
-
- /*
- disable, enable menus -- find out if clipboard has a PICT or should be considered empty
- (may want to use ScrapInfo to minimize overhead.)
- */
-
- if ( GetScrap (NIL, 'PICT', &scrap_offset) == noTypeErr )
- {
- clipboard_empty = TRUE;
- }
- else
- {
- clipboard_empty = FALSE;
- }
-
- if ( Current_Window != FrontWindow() )
- {
- Current_Window = FrontWindow();
- Update_Menus( Current_Window );
- DrawMenuBar(); /* handle dimming of entire menus */
- }
- else
- {
- Update_Menus( Current_Window ); /* dimming of menu items */
- }
-
- if (GetNextEvent (everyEvent, &myEvent))
- {
- code = FindWindow (myEvent.where, &whichWindow);
-
- switch (myEvent.what)
- {
- case mouseDown:
- if (code == inMenuBar)
- {
- mResult = MenuSelect (myEvent.where);
- theMenu = HiWord (mResult);
- theItem = LoWord (mResult);
- HandleMenu (&doneFlag, theMenu, theItem, &theInput);
- }
-
- if ((code == inDrag) && (whichWindow != NIL))
- {
- if ( (myEvent.modifiers & cmdKey == 0) && (whichWindow != FrontWindow()) )
- {
- SelectWindow( whichWindow );
- } /* if commandkey is down, then user can drag a un-selected window */
- else
- {
- DragWindow (whichWindow, myEvent.where, &dragRect);
- }
- }
-
- if (code == inGrow)
- {
-
- switch (GetWRefCon (whichWindow))
- {
- case 9:
- grow_flourine (&myEvent.where, whichWindow);
- break;
- case 8:
- grow_proton (&myEvent.where, whichWindow);
- break;
- case 10:
- grow_result (&myEvent.where, whichWindow);
- break;
- }
-
- }
-
- /* if (code == inGoAway) -- we don't have go-away boxes in our windows */
-
- if (code == inContent)
- {
- if (whichWindow != FrontWindow ())
- {
- SelectWindow (whichWindow);
- }
- else
- {
- switch (GetWRefCon (whichWindow))
- {
- case 9:
- Do_flourine (&myEvent);
- break;
- case 8:
- Do_proton (&myEvent);
- break;
- case 10:
- Do_Result (&myEvent);
- break;
- }
- }
- }
-
- if (code == inSysWindow) /* See if a DA selection */
- { /* Let the OS do it */
- SystemClick (&myEvent, whichWindow);
- }
-
- if ((code == inZoomIn) || (code == inZoomOut))
- { /* Start zoom */
- if (whichWindow != NIL)
- {
- switch (GetWRefCon (whichWindow))
- {
- case 9:
- zoom_flourine (&myEvent.where, (WindowPeek) whichWindow, code);
- break;
- case 8:
- zoom_proton (&myEvent.where, (WindowPeek)whichWindow, code);
- break;
- case 10:
- zoom_result (&myEvent.where, (WindowPeek) whichWindow, code);
- break;
- }
- }
- }
-
- break; /* End of mouseDown */
-
- case keyDown:
- case autoKey:
- ch = myEvent.message & charCodeMask;
- if (myEvent.modifiers & cmdKey)
- {
- mResult = MenuKey (ch);
- theMenu = HiWord (mResult);
- theItem = LoWord (mResult);
- if (theMenu != 0)
- HandleMenu (&doneFlag, theMenu, theItem, &theInput);
- if (((ch == 'x') || (ch == 'X')) && (theInput != NIL))
- TECut (theInput); /* Handle a Cut in a TE area*/
- if (((ch == 'c') || (ch == 'C')) && (theInput != NIL))
- TECopy (theInput); /* Handle a Copy in a TE are*/
- if (((ch == 'v') || (ch == 'V')) && (theInput != NIL))
- TEPaste (theInput); /* Handle a Paste in a TE ar*/
- }
- else if (theInput != NIL)
- TEKey (ch, theInput);
- break;
-
- case updateEvt:
- whichWindow = (WindowPtr)myEvent.message;
- switch (GetWRefCon (whichWindow))
- {
- case 9:
- UpDate_flourine (whichWindow);
- break;
- case 8:
- UpDate_proton (whichWindow);
- break;
- case 10:
- UpDate_Result (whichWindow);
- break;
- }
- break;
-
- case diskEvt: /* Disk inserted event */
- if (HiWord (myEvent.message) != 0)
- { /* due to unformatted diskette inserted */
- myEvent.where.h = ( (screenBits.bounds.right - screenBits.bounds.left) / 2)
- - (304 / 2); /* Center horz */
- myEvent.where.v = ( (screenBits.bounds.bottom - screenBits.bounds.top) / 3)
- - (104 / 2); /* Top 3ed vertically */
- InitCursor (); /* Make sure it has an arrow cursor */
- theItem = DIBadMount (myEvent.where, myEvent.message);
- }
- break; /* End of DiskEvt */
-
- case activateEvt: /* Window activated event - how about deactivate?? */
- whichWindow = (WindowPtr)myEvent.message;
- if ((whichWindow != NIL))
- {
- switch (GetWRefCon (whichWindow))
- {
- case 9:
- activate_flourine (whichWindow, myEvent.modifiers);
- break;
- case 8:
- activate_proton (whichWindow, myEvent.modifiers);
- break;
- case 10:
- activate_result (whichWindow, myEvent.modifiers);
- break;
- }
- }
- break;
-
-
- default:
- break;
-
- }
-
- }
- }
- while (doneFlag == FALSE);
-
- }
-
- /* End of MAIN */
-